home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / TEECHART / Delphi1_And_Delphi2 / EXAMPLES / OTHER / Html Table / UDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-10-24  |  3.6 KB  |  118 lines

  1. unit Udemo;
  2.  
  3. interface
  4.  
  5. { Demo of TImporter component, located at TEEHTM.PAS unit }
  6. uses
  7.   WinTypes,WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  8.   TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls, teeHTM;
  9.  
  10. type
  11.   TForm1 = class(TForm)
  12.     Chart1: TChart;
  13.     Panel1: TPanel;
  14.     Button1: TButton;
  15.     ComboBox1: TComboBox;
  16.     Button2: TButton;
  17.     Button8: TButton;
  18.     Label1: TLabel;
  19.     procedure Button1Click(Sender: TObject);
  20.     procedure Button2Click(Sender: TObject);
  21.     procedure Button8Click(Sender: TObject);
  22.     procedure FormCreate(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.     Importer1: TImporter;
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36. uses TeeSurfa,Editchar,ChartPro;
  37.  
  38. procedure TForm1.Button2Click(Sender: TObject);
  39. begin
  40.   EditChart(Self,Chart1);  { <-- show the Chart editor dialog }
  41. end;
  42.  
  43. procedure TForm1.Button1Click(Sender: TObject);
  44. var tmp:TChartSeries;
  45. begin
  46.   { Prepare the TImporter properties according to the kind of
  47.     htm table we want to load....
  48.   }
  49.   Importer1.CloneCount:=0;       { <-- don't clone series automatically... }
  50.   Case ComboBox1.ItemIndex of
  51.        0: With Importer1 do     { dollar.htm }
  52.           begin
  53.             TitleRows:=0;       { <-- number of rows with titles... }
  54.             XColumn:=1;         { <-- where is the "X" value in the table columns ? }
  55.             XDateTime:=True;        { <-- are X values DateTime? }
  56.             YColumn:=3;         { <-- where is the "Y" value in the table columns ? }
  57.             LabelColumn:=-1;    { <-- where is the LABEL in the table columns ? }
  58.             InvertedDate:=True;     { <-- are X Date values inverted?  ( YY/MM/DD ) }
  59.             SwapDecimal:=True;      { <-- have to swap "." with "," ? }
  60.           end;
  61.        1: With Importer1 do  { world.htm }
  62.           begin
  63.             TitleRows:=0;
  64.             XColumn:=-1;
  65.             XDateTime:=False;
  66.             YColumn:=3;
  67.             LabelColumn:=0;
  68.             AddCloneCols([4,5,6,7,8,9]);  { <-- duplicate Series1 for other columns }
  69.             SwapDecimal:=True;
  70.           end;
  71.        2: With Importer1 do { temperat.htm }
  72.           begin
  73.             TitleRows:=1;
  74.             XColumn:=-1;
  75.             XDateTime:=False;
  76.             LabelColumn:=0;
  77.             YColumn:=1;
  78.             AddCloneCols([2,3,4,5,6,7,8]);
  79.             SwapDecimal:=True;
  80.           end;
  81.        3: With Importer1 do  { tv.htm }
  82.           begin
  83.             TitleRows:=0;
  84.             XColumn:=-1;
  85.             XDateTime:=False;
  86.             LabelColumn:=2;
  87.             YColumn:=6;
  88.             SwapDecimal:=True;
  89.             Chart1.Legend.Visible:=False;
  90.             tmp:=Chart1[0];
  91.             ChangeSeriesType(tmp,THorizBarSeries);  { <-- change to Horizontal Bar }
  92.             { prepare some esthetic series properties... }
  93.             Chart1[0].ColorEachPoint:=True;
  94.             Chart1[0].Marks.Visible:=True;
  95.             Chart1[0].Marks.Style:=smsValue;
  96.             Chart1.LeftAxis.Inverted:=True;
  97.             Chart1.LeftAxis.LabelsSeparation:=0;
  98.           end;
  99.   end;
  100.   { Do it !!!! }
  101.   Importer1.Chart:=Chart1;
  102.   Importer1.ImportHTMTable(ComboBox1.Text);  { <-- load the HTM Table !!! }
  103. end;
  104.  
  105. procedure TForm1.Button8Click(Sender: TObject);
  106. begin
  107.   SaveSeriesToHTM('series1.htm',Chart1[0])
  108. end;
  109.  
  110. procedure TForm1.FormCreate(Sender: TObject);
  111. begin
  112.   Importer1:=TImporter.Create(Self); { <-- in teeHTM.pas unit }
  113.   ComboBox1.ItemIndex:=0;
  114.   Chart1.AddSeries(TLineSeries.Create(Self));
  115. end;
  116.  
  117. end.
  118.